package com.lb.statck.mapper.order;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lb.statck.pojo.dto.OrderDTO;
import com.lb.statck.pojo.dto.OrderQueryDto;
import com.lb.statck.pojo.vo.OrderVo;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper extends BaseMapper<OrderVo> {

    @Select("SELECT o.*, p.imageurl FROM `order` o LEFT JOIN products p ON o.product_code = p.product_code WHERE o.userid = #{userid}")
    List<OrderVo> orderVoList(int userid);
    @Insert("INSERT INTO `order` (createtime,storename,userid, price, product_code,payorderid,status,url) VALUES (#{createTime},#{storename},#{userid}, #{Price}, #{productCode},#{orderId},#{status},#{url})")
    void insertOrder(OrderDTO orderVo);
    @Select("select * from  `order` where  payorderid=#{orderId}")
    OrderVo getOrder(String orderId);
    @Select("SELECT price FROM `order` WHERE payorderid=#{orderNo}")
    BigDecimal getPrice(String orderNo);
    List<OrderVo> queryOrders(@Param("queryDto") OrderQueryDto queryDto);
    @Update("UPDATE `order` SET status = 2 WHERE payorderid = #{orderId}")
    void updateOrder(OrderDTO orderVo);

    OrderVo getOrderByPayOrder(String orderId);
    @Insert("INSERT INTO `order` (price,num, payorderid,  status ,product_code,createtime,userid) VALUES (#{price},#{num},#{payorderid},1,#{product_code},#{createtime},#{userid})")
    void inserts(OrderVo orderVo);

    OrderVo getOrders(String order);
    @Select("SELECT o.*, p.imageurl FROM `order` o LEFT JOIN products p ON o.product_code = p.product_code WHERE o.payorderid = #{orderId}")
    OrderVo getOrder1(OrderDTO orderVo);

    List<Map<String, Object>> getOrderDetail(OrderDTO orderVo);

    OrderVo selects(OrderVo orderVo);
}
